home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 934 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.8 KB

  1. Path: dawn.mmm.com!news
  2. From: kjhopps@mmm.com (Kevin J Hopps)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Exceptions vs. assertions
  5. Date: 8 Jan 1996 14:48:01 GMT
  6. Organization: 3M - St. Paul, MN  55144-1000 US
  7. Message-ID: <4crar1$9oh@dawn.mmm.com>
  8. References: <4cbfac$kst@dawn.mmm.com> <DKMJsE.LH5@falcon.daytonoh.attgis.com>
  9. Reply-To: kjhopps@mmm.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Dick Menninger (Dick.Menninger@DaytonOH.ATTGIS.COM) wrote:
  13.  
  14. > > ==========Kevin J Hopps, 1/2/96==========
  15. >  
  16. > > Chris Page (page@tiac.net) wrote:
  17. > > > lalit@gramercy.ios.com (lalit gidwani) wrote:
  18.  
  19. > [stuff deleted]
  20.  
  21. > > > is this: If I expect a condition to occur during normal operation of
  22. > > > my program, then I do not use exceptions for it.  I use exceptions,
  23. > > > only for exceptionally conditions, which I do not expect to
  24. > occur, but
  25. > > > I have to anticipate.
  26. > > 
  27. > > This is a good approach.  The issue of whether to throw exceptions or
  28. > > return status values is best decided by how likely the failure is than
  29. > > by how catastrophic it is.  (Besides, the caller of a function knows
  30. > > better than the function itself how costly the failure is.)
  31.  
  32. > Exceptions are a control paradigm.  Would you choose any
  33. > other control paradigm based on frequency or importance
  34. > of the issue being modeled (programmed)? It would seem that
  35. > the choice should be based on trying for the best expression
  36. > of the problem.
  37.  
  38. Making decisions this way would seem to make it easier to understand
  39. what the code is doing.  This is an important consideration, but it
  40. is not the only consideration.
  41.  
  42. > I suspect there are problems to be modeled
  43. > where they are best expressed with an exception used for
  44. > the success path.  In fact, that is one of the reasons I push
  45. > for multiple simultaneous exceptions being valid in the language
  46. > (so you can have an error exception while returning a success
  47. > exception).
  48.  
  49. I'm not sure what you mean by "multiple simultaneous exceptions."
  50.  
  51. > Such problems are likely to be related to problems
  52. > where multi-level breaks (usually simulated by a goto) are very
  53. > helpful in clarifying the expression of the model.  For such
  54. > problems, the solution may perform better with an exception
  55. > for success.
  56.  
  57. Even if I thought that using a goto to simulate a multi-level break
  58. was very helpful in clarifying the expression of the model, I would
  59. probably avoid it if it both
  60.     a) was likely to occur with significant frequency, and
  61.     b) made the code 2-3 times slower.
  62. --
  63. Kevin J. Hopps                  e-mail: kjhopps@mmm.com
  64. 3M Company                      phone:  (612) 737-4643
  65. 3M Center, Bldg. 235-2D-57      fax:    (612) 737-2700
  66. St. Paul, MN 55144-1000         Opinions are my own.  I don't speak for 3M.
  67.     But 3M speaks for me -- I did not write the following line:
  68.  
  69. Opinions expressed herein are my own and may not represent those of 3M.
  70.